﻿package mortal.game.view.chat.chatPrivate
{
    import com.mui.controls.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.map3D.*;
    import mortal.game.view.common.*;

    public class ChatGuildIcon extends ChatIconBase
    {
        private var _chatBtn:GLoadingButton;
        private var _textNumBg:GBitmap;
        private var _textNum:GTextFiled;
        private var _unReadNum:int = 0;

        public function ChatGuildIcon()
        {
            this.layer = LayerManager.uiLayer;
            return;
        }// end function

        override protected function create() : void
        {
            this._chatBtn = UIFactory.gLoadingButton(ResFileConst.ChatTipBtn, 0, 0, 44, 44, this);
            this._textNumBg = UIFactory.gBitmap(ImagesConst.NumberBg, 27, -5, this);
            this._textNum = UIFactory.gTextField("1", 27, -4, 24, 20, this, GlobalStyle.textFormatPutong.center());
            this._textNum.mouseEnabled = false;
            this.updateTextNum();
            return;
        }// end function

        protected function updateTextNum() : void
        {
            this._textNum.text = this._unReadNum.toString();
            this._textNumBg.visible = this._unReadNum > 0;
            this._textNum.visible = this._unReadNum > 0;
            return;
        }// end function

        override protected function onClick(event:MouseEvent) : void
        {
            super.onClick(event);
            return;
        }// end function

        override protected function onTargetWindowShow(event:Event) : void
        {
            this._unReadNum = 0;
            this.updateTextNum();
            return;
        }// end function

        override public function getMsg() : void
        {
            if (_targetWindow && _targetWindow.isHide)
            {
                var _loc_1:String = this;
                var _loc_2:* = this._unReadNum + 1;
                _loc_1._unReadNum = _loc_2;
                this.updateTextNum();
            }
            this.show();
            return;
        }// end function

        override public function hide() : void
        {
            this._unReadNum = 0;
            this.updateTextNum();
            super.hide();
            return;
        }// end function

        override public function stageResize() : void
        {
            this.x = SceneRange.display.width / 2 + 185;
            this.y = SceneRange.display.height - 125;
            return;
        }// end function

    }
}
